from django import template

register=template.Library()

@register.inclusion_tag("rbac/menu.html")
def get_menu(request,):
    # 获取当前用户可以放到菜单栏中的权限
    menu_permission_list = request.session["menu_permission_list"]
    print(2222222)
    print(list(reversed(menu_permission_list)))

    return {"menu_permission_list":list(reversed(menu_permission_list))}

@register.simple_tag()
def jenkins_list(name,env,group):
    res = group + "-" + env + "_" + name
    # print(res)
    return res

@register.inclusion_tag("result.html")
def ingress_deal(domain,request_path):
    # print(444444)
    # print("domain",domain.split("\n"))
    domain = domain.split("\n")
    domain_list = []
    for dd in domain:
        if dd:
            domain_list.append(dd)
    # gg = ""
    # for dd in domain_list:
    #     gg += "<br><a href = 'http://%s%s'> http://%s%s</a></br>" % (dd,request_path,dd,request_path)
    return {"domain_list":domain_list,"request_path":request_path}
